package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author lanhaif
 * @since 2022-08-22
 */
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

//    添加
    @PostMapping("addSubject")
    public R add(MultipartFile file){
//        获取上传过来的文件，把文件内容读取出
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }

//    课程分了列表
    @GetMapping("getAllSubject")
    public R getAllSubject(){
//        list集合中的泛型是一集分类
        List<OneSubject> list=eduSubjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }

}

